<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


//include_once dirname(dirname(__DIR__)).'/third_party/phpcode_shield.php';		//加载防注入代码
class Wxauth_2 extends CI_Controller {
	
	private $dealerNumber;
	
	
	function __construct(){
		header('Content-Type: text/html; charset=utf-8'); 
		parent::__construct();
		$this->load->helper('url');
		
		$this->dealerNumber = 2;
	}
	
	/**
	 * Index Page for this controller.
	 *
	 */
	public function index()
	{
		show_404();
	}
	
	
	/*
		微信支付
	*/
	public function wxpayCallback()
	{
		log_message('error', "function(wxpayCallback):get  : "." in file".__FILE__." on Line ".__LINE__);
		
		$fileContent = file_get_contents("php://input");
		$postObj = simplexml_load_string($fileContent, 'SimpleXMLElement', LIBXML_NOCDATA);
		$postArray = get_object_vars($postObj);

		$dealer_num = $this->dealerNumber;
		//var_dump($postArray);
		$this->load->model('payment/wxpay_model', '', true);
		$result = $this->wxpay_model->wxpayCallBack($postArray,$dealer_num);
		//log_message('error', "function(wxpayCallback):result:".$result." in file".__FILE__." on Line ".__LINE__);
		echo $result;
	}





	public function updateUserInfo()
	{
		$this->load->model('wechat_model','',true);
		$update_result = $this->wechat_model->updateUserInfo($_POST);
		return true;
	}


	public function searchRefundRedenvelop()
	{
		$dealer_num = $this->dealerNumber;

		$request_ary['dealer_num'] = $dealer_num;
		$this->load->model('activity/redenvelop_model','',true);
		$redenvelop_result = $this->redenvelop_model->searchRefundRedenvelop($request_ary);
	
		echo $redenvelop_result;
	}

	/************************************************
						汇总首页
	*************************************************/
	/*
		汇总首页
	*/
	public function getMainHomeOpenID()
	{
		log_message('error', "function(getMainHomeOpenID):wx direct state:"." in file".__FILE__." on Line ".__LINE__);
		
		if(isset($_GET['code']) )
		{
			$code = $_GET['code'];
			$state = $_GET['state'];

			$dist_code = "";
			if(strpos($state, "x") !== false)
			{
				$state_array = explode("x",$state);
				$dist_code = $state_array[1];
			}

			$dealer_num = $this->dealerNumber;
			$DelaerConst = "Dealer_".$dealer_num;
			
			$this->load->model('wechat_model','',true);
			$result = $this->wechat_model->getInfoOpenid($dealer_num,$code);
			
			if(is_array($result) && isset($result['openid']))
			{
				$url = "http://".$DelaerConst::DWxAuth_SkipHost."/game/mainhome?dealer_num=".$dealer_num."&dist_code=".$dist_code;
				
				$direct_url = 'http://'.$DelaerConst::DWxAuth_SkipHost.'/game/skipUrl?open_id='.$result['openid'].'&url='.base64_encode($url);
				
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/game/mainhome?dealer_num=".$dealer_num."&dist_code=".$dist_code;
				
				Header("Location:".$direct_url);
			}
			else
			{
				log_message('error', "function(getMainHomeOpenID):can not get open_id in file".__FILE__." on Line ".__LINE__);
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/d2/main/".$dealer_num."/".$dist_code;
				Header("Location:".$direct_url);
			}
		}
		else
		{
			log_message('error', "function(getMainHomeOpenID):lack of code in file".__FILE__." on Line ".__LINE__);
			echo '{"result":"-1"}';
		}
	}
	/************************************************
						诈金花
	*************************************************/
	/*
		诈金花房间
	*/
	public function getGameOpenIDRoom()
	{
		if(isset($_GET['code']) )
		{
			$code = $_GET['code'];
			$state = $_GET['state'];

			$room_number = $state;
			$dist_code = "";
			if(strpos($state, "x") !== false)
			{
				$state_array = explode("x",$state);
				$room_number = $state_array[0];
				$dist_code = $state_array[1];
			}

			$dealer_num = $this->dealerNumber;
			$DelaerConst = "Dealer_".$dealer_num;
			
			$this->load->model('wechat_model','',true);
			$result = $this->wechat_model->getInfoOpenid($dealer_num,$code);

			if(is_array($result) && isset($result['openid']))
			{
				$url = "http://".$DelaerConst::DWxAuth_SkipHost."/game/main?room_number=".$room_number."&dealer_num=".$dealer_num."&dist_code=".$dist_code;
				
				$direct_url = 'http://'.$DelaerConst::DWxAuth_SkipHost.'/game/skipUrl?open_id='.$result['openid'].'&url='.base64_encode($url);
				
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/game/main?room_number=".$room_number."&dealer_num=".$dealer_num."&dist_code=".$dist_code;
				
				Header("Location:".$direct_url);
			}
			else
			{
				log_message('error', "function(getGameOpenIDRoom):can not get open_id in file".__FILE__." on Line ".__LINE__);
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/d2/fg/".$dealer_num.'/'.$room_number.'/'.$dist_code;
				Header("Location:".$direct_url);
			}
		}
		else
		{
			log_message('error', "function(getGameOpenIDRoom):lack of code in file".__FILE__." on Line ".__LINE__);
			echo '{"result":"-1"}';
		}
	}
	
	
	/************************************************
						斗牛
	*************************************************/
	/*
		房间
	*/
	public function getGameOpenIDRoomBull()
	{
		if(isset($_GET['code']) )
		{
			$code = $_GET['code'];
			$state = $_GET['state'];

			$room_number = $state;
			$dist_code = "";
			if(strpos($state, "x") !== false)
			{
				$state_array = explode("x",$state);
				$room_number = $state_array[0];
				$dist_code = $state_array[1];
			}

			$dealer_num = $this->dealerNumber;
			$DelaerConst = "Dealer_".$dealer_num;
			
			$this->load->model('wechat_model','',true);
			$result = $this->wechat_model->getInfoOpenid($dealer_num,$code);

			if(is_array($result) && isset($result['openid']))
			{
				$url = "http://".$DelaerConst::DWxAuth_SkipHost."/game/tableBull?&room_number=".$room_number."&dealer_num=".$dealer_num."&dist_code=".$dist_code;
				
				$direct_url = 'http://'.$DelaerConst::DWxAuth_SkipHost.'/game/skipUrl?open_id='.$result['openid'].'&url='.base64_encode($url);
				
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/game/tableBull?&room_number=".$room_number."&dealer_num=".$dealer_num."&dist_code=".$dist_code;
				
				Header("Location:".$direct_url);
			}
			else
			{
				log_message('error', "function(getGameOpenIDRoomBull):can not get open_id in file".__FILE__." on Line ".__LINE__);
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/d2/bfg/".$dealer_num.'/'.$room_number.'/'.$dist_code;
				Header("Location:".$direct_url);
			}
		}
		else
		{
			log_message('error', "function(getGameOpenIDRoomBull):lack of code in file".__FILE__." on Line ".__LINE__);
			echo '{"result":"-1"}';
		}
	}
	/*
		房间
	*/
	public function getGameOpenIDRoomBull9()
	{
		if(isset($_GET['code']) )
		{
			$code = $_GET['code'];
			$state = $_GET['state'];

			$room_number = $state;
			$dist_code = "";
			if(strpos($state, "x") !== false)
			{
				$state_array = explode("x",$state);
				$room_number = $state_array[0];
				$dist_code = $state_array[1];
			}

			$dealer_num = $this->dealerNumber;
			$DelaerConst = "Dealer_".$dealer_num;
			
			$this->load->model('wechat_model','',true);
			$result = $this->wechat_model->getInfoOpenid($dealer_num,$code);

			if(is_array($result) && isset($result['openid']))
			{
				$url = "http://".$DelaerConst::DWxAuth_SkipHost."/game/bull9?&room_number=".$room_number."&dealer_num=".$dealer_num."&dist_code=".$dist_code;
				
				$direct_url = 'http://'.$DelaerConst::DWxAuth_SkipHost.'/game/skipUrl?open_id='.$result['openid'].'&url='.base64_encode($url);
				
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/game/bull9?&room_number=".$room_number."&dealer_num=".$dealer_num."&dist_code=".$dist_code;
				
				Header("Location:".$direct_url);
			}
			else
			{
				log_message('error', "function(getGameOpenIDRoomBull9):can not get open_id in file".__FILE__." on Line ".__LINE__);
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/d2/bfg9/".$dealer_num.'/'.$room_number.'/'.$dist_code;
				Header("Location:".$direct_url);
			}
		}
		else
		{
			log_message('error', "function(getGameOpenIDRoomBull9):lack of code in file".__FILE__." on Line ".__LINE__);
			echo '{"result":"-1"}';
		}
	}
	/************************************************
						斗地主
	*************************************************/
	/*
		房间
	*/
	public function getGameOpenIDRoomLandlord()
	{
		if(isset($_GET['code']) )
		{
			$code = $_GET['code'];
			$state = $_GET['state'];

			$room_number = $state;
			$dist_code = "";
			if(strpos($state, "x") !== false)
			{
				$state_array = explode("x",$state);
				$room_number = $state_array[0];
				$dist_code = $state_array[1];
			}

			$dealer_num = $this->dealerNumber;
			$DelaerConst = "Dealer_".$dealer_num;
			
			$this->load->model('wechat_model','',true);
			$result = $this->wechat_model->getInfoOpenid($dealer_num,$code);

			if(is_array($result) && isset($result['openid']))
			{
				$url = "http://".$DelaerConst::DWxAuth_SkipHost."/game/landlord?&room_number=".$room_number."&dealer_num=".$dealer_num."&dist_code=".$dist_code;
				
				$direct_url = 'http://'.$DelaerConst::DWxAuth_SkipHost.'/game/skipUrl?open_id='.$result['openid'].'&url='.base64_encode($url);
				
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/game/landlord?&room_number=".$room_number."&dealer_num=".$dealer_num."&dist_code=".$dist_code;
				
				Header("Location:".$direct_url);
			}
			else
			{
				log_message('error', "function(getGameOpenIDRoomLandlord):can not get open_id in file".__FILE__." on Line ".__LINE__);
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/d2/lfg/".$dealer_num.'/'.$room_number.'/'.$dist_code;
				Header("Location:".$direct_url);
			}
		}
		else
		{
			log_message('error', "function(getGameOpenIDRoomLandlord):lack of code in file".__FILE__." on Line ".__LINE__);
			echo '{"result":"-1"}';
		}
	}


	/************************************************
						广东麻将
	*************************************************/
	/*
		房间
	*/
	public function getGameOpenIDRoomGDMJ()
	{
		if(isset($_GET['code']) )
		{
			$code = $_GET['code'];
			$state = $_GET['state'];

			$room_number = $state;
			$dist_code = "";
			if(strpos($state, "x") !== false)
			{
				$state_array = explode("x",$state);
				$room_number = $state_array[0];
				$dist_code = $state_array[1];
			}

			$dealer_num = $this->dealerNumber;
			$DelaerConst = "Dealer_".$dealer_num;
			
			$this->load->model('wechat_model','',true);
			$result = $this->wechat_model->getInfoOpenid($dealer_num,$code);

			if(is_array($result) && isset($result['openid']))
			{
				$url = "http://".$DelaerConst::DWxAuth_SkipHost."/game/majiang?&room_number=".$room_number."&dealer_num=".$dealer_num."&dist_code=".$dist_code;
				
				$direct_url = 'http://'.$DelaerConst::DWxAuth_SkipHost.'/game/skipUrl?open_id='.$result['openid'].'&url='.base64_encode($url);
				
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/game/majiang?&room_number=".$room_number."&dealer_num=".$dealer_num."&dist_code=".$dist_code;
				
				Header("Location:".$direct_url);
			}
			else
			{
				log_message('error', "function(getGameOpenIDRoomGDMJ):can not get open_id in file".__FILE__." on Line ".__LINE__);
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/d2/gdmjfg/".$dealer_num.'/'.$room_number.'/'.$dist_code;
				Header("Location:".$direct_url);
			}
		}
		else
		{
			log_message('error', "function(getGameOpenIDRoomGDMJ):lack of code in file".__FILE__." on Line ".__LINE__);
			echo '{"result":"-1"}';
		}
	}

	/************************************************
						江西滚轮子
	*************************************************/
	/*
		房间
	*/
	public function getOpenIDScroll()
	{
		if(isset($_GET['code']) )
		{
			$code = $_GET['code'];
			$state = $_GET['state'];

			$room_number = $state;
			$dist_code = "";
			if(strpos($state, "x") !== false)
			{
				$state_array = explode("x",$state);
				$room_number = $state_array[0];
				$dist_code = $state_array[1];
			}

			$dealer_num = $this->dealerNumber;
			$DelaerConst = "Dealer_".$dealer_num;
			
			$this->load->model('wechat_model','',true);
			$result = $this->wechat_model->getInfoOpenid($dealer_num,$code);

			if(is_array($result) && isset($result['openid']))
			{
				
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/game/scroll?&room_number=".$room_number."&dealer_num=".$dealer_num."&dist_code=".$dist_code;
				
				Header("Location:".$direct_url);
			}
			else
			{
				log_message('error', "function(getOpenIDScroll):can not get open_id in file".__FILE__." on Line ".__LINE__);
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/d2/scrollfg/".$dealer_num.'/'.$room_number.'/'.$dist_code;
				Header("Location:".$direct_url);
			}
		}
		else
		{
			log_message('error', "function(getOpenIDScroll):lack of code in file".__FILE__." on Line ".__LINE__);
			echo '{"result":"-1"}';
		}
	}




	/************************************************
						活动
	*************************************************/
	/*
		红包
	*/
	public function getGameOpenIDRedEnvelop()
	{
		if(isset($_GET['code']) )
		{
			$code = $_GET['code'];
			$state = $_GET['state'];

			$dealer_num = $this->dealerNumber;
			$DelaerConst = "Dealer_".$dealer_num;
			
			$this->load->model('wechat_model','',true);
			$result = $this->wechat_model->getInfoOpenid($dealer_num,$code);
			if(is_array($result) && isset($result['openid']))
			{
				$url = "http://".$DelaerConst::DWxAuth_SkipHost."/activity/redpackageDetail?red_code=".$state."&dealer_num=".$dealer_num;
				
				$direct_url = 'http://'.$DelaerConst::DWxAuth_SkipHost.'/game/skipUrl?open_id='.$result['openid'].'&url='.base64_encode($url);
				
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/activity/redpackageDetail?red_code=".$state."&dealer_num=".$dealer_num;
				
				Header("Location:".$direct_url);
			}
			else
			{
				log_message('error', "function(getGameOpenIDRedEnvelop):can not get open_id in file".__FILE__." on Line ".__LINE__);
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/d2/re/".$dealer_num."/".$state;
				Header("Location:".$direct_url);
			}
		}
		else
		{
			log_message('error', "function(getGameOpenIDRedEnvelop):lack of code in file".__FILE__." on Line ".__LINE__);
			echo '{"result":"-1"}';
		}
	}

	/*
		红包列表
	*/
	public function getGameOpenIDRedEnvelopList()
	{
		if(isset($_GET['code']) )
		{
			$code = $_GET['code'];
			$state = $_GET['state'];

			$dealer_num = $this->dealerNumber;
			$DelaerConst = "Dealer_".$dealer_num;
			
			$this->load->model('wechat_model','',true);
			$result = $this->wechat_model->getInfoOpenid($dealer_num,$code);
			if(is_array($result) && isset($result['openid']))
			{
				$url = "http://".$DelaerConst::DWxAuth_SkipHost."/game/homepage?dealer_num=".$dealer_num;
				
				$direct_url = 'http://'.$DelaerConst::DWxAuth_SkipHost.'/game/skipUrl?open_id='.$result['openid'].'&url='.base64_encode($url);
				
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/game/homepage?dealer_num=".$dealer_num;
				
				Header("Location:".$direct_url);
			}
			else
			{
				log_message('error', "function(getGameOpenIDRedEnvelop):can not get open_id in file".__FILE__." on Line ".__LINE__);
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/d2/relist/".$dealer_num;
				Header("Location:".$direct_url);
			}
		}
		else
		{
			log_message('error', "function(getGameOpenIDRedEnvelop):lack of code in file".__FILE__." on Line ".__LINE__);
			echo '{"result":"-1"}';
		}
	}
	/*
		创建红包
	*/
	public function getGameOpenIDCreateRedEnvelop()
	{
		if(isset($_GET['code']) )
		{
			$code = $_GET['code'];
			$state = $_GET['state'];
			$dealer_num = $this->dealerNumber;
			$DelaerConst = "Dealer_".$dealer_num;
			
			$this->load->model('wechat_model','',true);
			$result = $this->wechat_model->getInfoOpenid($dealer_num,$code);
			if(is_array($result) && isset($result['openid']))
			{
				$url = "http://".$DelaerConst::DWxAuth_SkipHost."/activity/redpackage?dealer_num=".$dealer_num;
				
				$direct_url = 'http://'.$DelaerConst::DWxAuth_SkipHost.'/game/skipUrl?open_id='.$result['openid'].'&url='.base64_encode($url);
				
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/activity/redpackage?dealer_num=".$dealer_num;
				
				Header("Location:".$direct_url);
			}
			else
			{
				log_message('error', "function(getGameOpenIDCreateRedEnvelop):can not get open_id in file".__FILE__." on Line ".__LINE__);
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/d2/cre/".$dealer_num;
				Header("Location:".$direct_url);
			}
		}
		else
		{
			log_message('error', "function(getGameOpenIDCreateRedEnvelop):lack of code in file".__FILE__." on Line ".__LINE__);
			echo '{"result":"-1"}';
		}
	}
	/*
		签到
	*/
	public function getGameOpenIDSign()
	{
		if(isset($_GET['code']) )
		{
			$code = $_GET['code'];
			$state = $_GET['state'];
			$dealer_num = $this->dealerNumber;
			$DelaerConst = "Dealer_".$dealer_num;
			
			$this->load->model('wechat_model','',true);
			$result = $this->wechat_model->getInfoOpenid($dealer_num,$code);
			if(is_array($result) && isset($result['openid']))
			{
				$url = "http://".$DelaerConst::DWxAuth_SkipHost."/activity/homeSign?dealer_num=".$dealer_num;
				
				$direct_url = 'http://'.$DelaerConst::DWxAuth_SkipHost.'/game/skipUrl?open_id='.$result['openid'].'&url='.base64_encode($url);
				
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/activity/homeSign?dealer_num=".$dealer_num;
				
				Header("Location:".$direct_url);
			}
			else
			{
				log_message('error', "function(getGameOpenIDSign):can not get open_id in file".__FILE__." on Line ".__LINE__);
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/d2/sign/".$dealer_num;
				Header("Location:".$direct_url);
			}
		}
		else
		{
			log_message('error', "function(getGameOpenIDSign):lack of code in file".__FILE__." on Line ".__LINE__);
			echo '{"result":"-1"}';
		}
	}
	/*
		转盘
	*/
	public function getGameOpenIDRedDial()
	{
		if(isset($_GET['code']) )
		{
			$code = $_GET['code'];
			$state = $_GET['state'];
			$dealer_num = $this->dealerNumber;
			$DelaerConst = "Dealer_".$dealer_num;
			
			$this->load->model('wechat_model','',true);
			$result = $this->wechat_model->getInfoOpenid($dealer_num,$code);
			if(is_array($result) && isset($result['openid']))
			{
				$url = "http://".$DelaerConst::DWxAuth_SkipHost."/activity/dial?dealer_num=".$dealer_num;
				
				$direct_url = 'http://'.$DelaerConst::DWxAuth_SkipHost.'/game/skipUrl?open_id='.$result['openid'].'&url='.base64_encode($url);
				
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/activity/dial?dealer_num=".$dealer_num;
				
				Header("Location:".$direct_url);
			}
			else
			{
				log_message('error', "function(getGameOpenIDRedDial):can not get open_id in file".__FILE__." on Line ".__LINE__);
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/d2/dial/".$dealer_num;
				Header("Location:".$direct_url);
			}
		}
		else
		{
			log_message('error', "function(getGameOpenIDRedDial):lack of code in file".__FILE__." on Line ".__LINE__);
			echo '{"result":"-1"}';
		}
	}
	/*
		老虎机
	*/
	public function getGameOpenIDSlot()
	{
		if(isset($_GET['code']) )
		{
			$code = $_GET['code'];
			$state = $_GET['state'];
			$dealer_num = $this->dealerNumber;
			$DelaerConst = "Dealer_".$dealer_num;
			
			$this->load->model('wechat_model','',true);
			$result = $this->wechat_model->getInfoOpenid($dealer_num,$code);
			if(is_array($result) && isset($result['openid']))
			{
				$url = "http://".$DelaerConst::DWxAuth_SkipHost."/activity/slotmachine?dealer_num=".$dealer_num;
				
				$direct_url = 'http://'.$DelaerConst::DWxAuth_SkipHost.'/game/skipUrl?open_id='.$result['openid'].'&url='.base64_encode($url);
				
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/activity/slotmachine?dealer_num=".$dealer_num;
				
				Header("Location:".$direct_url);
			}
			else
			{
				log_message('error', "function(getGameOpenIDSlot):can not get open_id in file".__FILE__." on Line ".__LINE__);
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/d2/slot/".$dealer_num;
				Header("Location:".$direct_url);
			}
		}
		else
		{
			log_message('error', "function(getGameOpenIDSlot):lack of code in file".__FILE__." on Line ".__LINE__);
			echo '{"result":"-1"}';
		}
	}


	/*
		分销成员列表
	*/
	public function getOpenIDCommissionList()
	{
		if(isset($_GET['code']) )
		{
			$code = $_GET['code'];
			$state = $_GET['state'];
			$dealer_num = $this->dealerNumber;
			$DelaerConst = "Dealer_".$dealer_num;
			
			$this->load->model('wechat_model','',true);
			$result = $this->wechat_model->getInfoOpenid($dealer_num,$code);
			if(is_array($result) && isset($result['openid']))
			{
				$url = "http://".$DelaerConst::DWxAuth_SkipHost."/dist/commissionList?dealer_num=".$dealer_num;
				
				$direct_url = 'http://'.$DelaerConst::DWxAuth_SkipHost.'/game/skipUrl?open_id='.$result['openid'].'&url='.base64_encode($url);
				
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/dist/commissionList?dealer_num=".$dealer_num;
				
				Header("Location:".$direct_url);
			}
			else
			{
				log_message('error', "function(getOpenIDCommissionList):can not get open_id in file".__FILE__." on Line ".__LINE__);
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/d2/clist/".$dealer_num;
				Header("Location:".$direct_url);
			}
		}
		else
		{
			log_message('error', "function(getOpenIDCommissionList):lack of code in file".__FILE__." on Line ".__LINE__);
			echo '{"result":"-1"}';
		}
	}
	/*
		分销成员列表
	*/
	public function getOpenIDDistList()
	{
		if(isset($_GET['code']) )
		{
			$code = $_GET['code'];
			$state = $_GET['state'];
			$dealer_num = $this->dealerNumber;
			$DelaerConst = "Dealer_".$dealer_num;
			
			$this->load->model('wechat_model','',true);
			$result = $this->wechat_model->getInfoOpenid($dealer_num,$code);
			if(is_array($result) && isset($result['openid']))
			{
				$url = "http://".$DelaerConst::DWxAuth_SkipHost."/dist/distList?dealer_num=".$dealer_num;
				
				$direct_url = 'http://'.$DelaerConst::DWxAuth_SkipHost.'/game/skipUrl?open_id='.$result['openid'].'&url='.base64_encode($url);
				
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/dist/distList?dealer_num=".$dealer_num;
				
				Header("Location:".$direct_url);
			}
			else
			{
				log_message('error', "function(getOpenIDDistList):can not get open_id in file".__FILE__." on Line ".__LINE__);
				$direct_url = "http://".$DelaerConst::DWxAuth_SkipHost."/d2/distList/".$dealer_num;
				Header("Location:".$direct_url);
			}
		}
		else
		{
			log_message('error', "function(getOpenIDDistList):lack of code in file".__FILE__." on Line ".__LINE__);
			echo '{"result":"-1"}';
		}
	}
	
}

/* End of file welcome.php */
